package com.wswy.wzcx.ui.pay

import com.wswy.wzcx.utils.StringUtils
import java.math.BigDecimal

class PayFineData(val preFineInfo: PreFineInfo) : PayBaseData(){


    private val fineFeeNum = StringUtils.parseToMoney(preFineInfo.fineFee)
    private val lateFeeNum = StringUtils.parseToMoney(preFineInfo.fineLateFee)
    private val serviceFeeNum = StringUtils.parseToMoney(preFineInfo.serviceFee)
    private val quickFeeNum = StringUtils.parseToMoney(preFineInfo.quickFee)


    val fineFeeText by lazy {
        fineFeeNum.toPlainString()
    }

    val lateFeeText by lazy {
        lateFeeNum.toPlainString()
    }

    val quickFeeText by lazy {
        quickFeeNum.toPlainString()
    }


    var quickService:Boolean = false


    fun getServiceFeeText():String{
        if (quickService){
            return serviceFeeNum.add(quickFeeNum).toPlainString()
        }else{
            return serviceFeeNum.toPlainString()
        }
    }

    fun getTotalFeeText() : String {

        var payMoney = BigDecimal.ZERO.add(fineFeeNum).add(lateFeeNum).add(serviceFeeNum)

        if (quickService && quickFeeNum.toFloat() > 0){
            payMoney = payMoney.add(quickFeeNum)
        }
        //如果有优惠券和填了处罚金额
        if (couponId >0 && couponFee?.toDouble()?:0.0 >0){
            payMoney = payMoney.minus(couponFee!!)
        }

        return payMoney.toPlainString()
    }
}